package com.demo.RemoteCall.FallBack;

import com.demo.RemoteCall.TaskManageRemoteCallService;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

/**
 * @author 李天航
 * 用于捕获异常信息的工场
 */
@Service
public class TaskManageFallBackFactory implements FallbackFactory<TaskManageRemoteCallService> {
    Logger logger = LoggerFactory.getLogger(TaskManageFallBackFactory.class);
    @Override
    public TaskManageRemoteCallService create(Throwable cause) {
        logger.error("出现异常，触发服务降级:"+cause.getMessage());
        cause.printStackTrace();
        return new TaskManageFallBack();
    }
}
